import {getUserInfo, removeUserInfo, setUserInfo} from "@/utils/auth";

export default {
  namespaced: true,
  state() {
    return {
      userInfo: getUserInfo()
    }
  },
  actions: {
  },
  mutations: {
    //设置用户信息
    setUserInfo(state,obj) {
      state.userInfo = obj
      setUserInfo(obj)
    },
    //移除token
    removeInfo(state) {
      removeUserInfo()
      state.userInfo = {}
    }
  },
  getters: {
    token(state) {
      return state.userInfo?.token || ''
    },
    name(state) {
      return state.userInfo?.name || ''
    }
  }
}
